FIX: All-numeric names exceeding Int32.MaxValue no longer throw when generating a unique name [UUM-145766] - #2464
Merged
Conversation
…generating a unique name [UUM-145766] StringHelpers.MakeUniqueName threw an OverflowException when generating a unique name from an all-numeric base name whose value exceeded Int32.MaxValue, causing the entered control scheme name to be discarded in favour of the default "New Control Scheme". StringHelpers.MakeUniqueName<TExisting>(string baseName, IEnumerable<TExisting> existingSet, Func<TExisting, string> getNameFunc) parsed the trailing digit run with int.Parse, which overflows for values above Int32.MaxValue. It now uses int.TryParse and, when the parse fails, keeps the full name as the base rather than stripping the digit suffix, so a numeric suffix is appended to make the name unique instead of an exception being thrown. Jira: https://jira.unity3d.com/browse/UUM-145766
…ix cannot overflow [UUM-145766] Guard the collision counter against overflowing when the trailing digits equal Int32.MaxValue. When an all-numeric base name parsed to exactly Int32.MaxValue, seeding the counter with trailingNumber + 1 overflowed int and the collision loop produced negative suffixes. The counter is now a long and the seeding addition is widened, so the suffix continues past Int32.MaxValue as a positive number. Jira: https://jira.unity3d.com/browse/UUM-145766
Collaborator
Author
|
@u-pr made suggested changes, review it again |
This comment was marked as resolved.
This comment was marked as resolved.
Codecov ReportAll modified and coverable lines are covered by tests ✅ @@ Coverage Diff @@
## develop #2464 +/- ##
========================================
Coverage 78.95% 78.95%
========================================
Files 767 767
Lines 140780 140805 +25
========================================
+ Hits 111153 111177 +24
- Misses 29627 29628 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…ened counter [UUM-145766] Parse the trailing numeric suffix as a long so names whose digits exceed Int32.MaxValue seed the counter instead of falling through to the append path. With namesTried already a long, long.TryParse lets a name like "item2147483648" increment to "item2147483649" on collision, rather than failing int.TryParse and producing "item21474836481". A name is only treated as an unseeded base when its digit run exceeds Int64.MaxValue. Jira: https://jira.unity3d.com/browse/UUM-145766
…euniquename-overflow # Conflicts: # Packages/com.unity.inputsystem/CHANGELOG.md
Collaborator
Author
|
@u-pr requested changes added, review it again |
Contributor
|
The changes look great! Switching to 📚 Additional Context
🤖 Helpful? 👍/👎 |
K-Tone
approved these changes
Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Note
This pull request was generated automatically. Please review carefully before merging.
StringHelpers.MakeUniqueName<TExisting>(string baseName, IEnumerable<TExisting> existingSet, Func<TExisting, string> getNameFunc)detects a trailing run of digits on the base name and seeds its counter from that number usingint.Parse. When the base name is entirely digits and its value exceedsInt32.MaxValue(for example451734859173),int.Parsethrows anOverflowException. In the Input Actions window this surfaces when adding a control scheme with such a name: the exception aborts naming and the scheme is created with the default"New Control Scheme"instead of the entered name.The trailing-digit branch now parses with
int.TryParse. When the parse fails, the branch is skipped and the full name is kept as the base rather than stripping the digit suffix, so the loop appends a numeric suffix to make the name unique (e.g. a colliding451734859173becomes4517348591731) instead of throwing. Names that fit inInt32are unaffected.Testing status & QA
StringHelperstest file to extend, and the fix is a self-contained guard around a single integer parse.Int32.MaxValue(e.g.451734859173); the scheme should now keep the entered name with noOverflowExceptionin the console, instead of falling back toNew Control Scheme. See https://jira.unity3d.com/browse/UUM-145766Overall Product Risks
StringHelpers; no public API surface touched)Comments to reviewers
N/A
Checklist
Before review:
Changed,Fixed,Addedsections.Area_CanDoX,Area_CanDoX_EvenIfYIsTheCase,Area_WhenIDoX_AndYHappens_ThisIsTheResult.During merge:
NEW: ___.FIX: ___.DOCS: ___.CHANGE: ___.RELEASE: 1.1.0-preview.3.